home *** CD-ROM | disk | FTP | other *** search
/ FM Towns: Free Software Collection 9 / FM Towns Free Software Collection 9.iso / t_os / shell / tsbgex / src / neko / draw.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-11-16  |  1.9 KB  |  105 lines

  1. #include "neko.h"
  2.  
  3. /* assume BITMAP_WIDTH==32 */
  4. void draw16(win, work, x, y, width, x2, y2, w, h)
  5. struct window *win;
  6. short *work;
  7. int x, y, width, x2, y2, w, h;
  8. {
  9.     extern BitmapData BitmapDataTable[];
  10.     extern int neko_id;
  11.     extern void _draw16();
  12.     
  13.     _draw16(work + y * width + x, (width - w)*2,     /* dst */
  14.             BitmapDataTable + neko_id, y2 * (win->w >> 3), 1<<x2,
  15.             w, h);
  16. }
  17.  
  18. void draw4(win, work, x, y, width, x2, y2, w, h)
  19. struct window *win;
  20. char *work;
  21. int x, y, width, x2, y2, w, h;
  22. {
  23.     extern BitmapData BitmapDataTable[];
  24.     extern int col16_0, col16_1;
  25.     extern int neko_id, BlackPixel, WhitePixel;
  26.     extern void _draw4();
  27.     
  28.     _draw4(work + y * width + x, width - w,     /* dst */
  29.             BitmapDataTable + neko_id, y2 * (win->w >> 3), 1<<x2,
  30.             w, h, col16_0, col16_1);
  31. }
  32.  
  33. void draw4f(win, work, x, y, width, x2, y2, w, h)
  34. struct window *win;
  35. char *work;
  36. int x, y, width, x2, y2, w, h;
  37. {
  38.     char *p;
  39.     extern int col16_f;
  40.     
  41.     p = work + y * width + x;
  42.     width -= w;
  43.     while (--h >= 0){
  44.         x = w;
  45.         while (--x >= 0)
  46.             *p++ = col16_f;
  47.         p += width;
  48.     }
  49. }
  50.  
  51. void draw16f(win, work, x, y, width, x2, y2, w, h)
  52. struct window *win;
  53. u_short *work;
  54. int x, y, width, x2, y2, w, h;
  55. {
  56.     u_short *p;
  57.     extern u_short col32f();
  58.     
  59.     p = work + y * width + x;
  60.     width -= w;
  61.     while (--h >= 0){
  62.         x = w;
  63.         while (--x >= 0)
  64.             *p++ = col32f(*p);
  65.         p += width ;
  66.     }
  67. }
  68.  
  69. int col32fmr = 90;
  70. int col32fmg = 90;
  71. int col32fmb = 90;
  72. int col32far = 0;
  73. int col32fag = 0;
  74. int col32fab = 0;
  75.  
  76. u_short col32f(u_short pixel)
  77. {
  78.     int r, g, b;
  79.     
  80.     b = pixel & 0x1f;
  81.     pixel >>= 5;
  82.     r = pixel & 0x1f;
  83.     pixel >>= 5;
  84.     g = pixel & 0x1f;
  85.  
  86.     r = _col32f(r, col32fmr, col32far);
  87.     g = _col32f(g, col32fmg, col32fag);
  88.     b = _col32f(b, col32fmb, col32fab);
  89.  
  90.     pixel = (g << 10) + (r << 5) + b;
  91.     return (pixel);
  92. }
  93.  
  94. _col32f(int x, int mul, int add)
  95. {
  96.     x *= mul;
  97.     x /= 100;
  98.     x += add;
  99.     if (x < 0)
  100.         x = 0;
  101.     else if (x >= 32)
  102.         x = 31;
  103.     return (x);
  104. }
  105.